import React ,{ Component,PropTypes } from 'react'
import { Link ,browserHistory} from 'react-router';
require('../css/ConfirmAdd.css');

class FailAdd extends Component {

	constructor (props, context) {
	    super(props, context)
			this.state = {
					moneyFail: '',
					msgContent: '',
					confirmT: ''
			}
	}

	componentWillMount() {
		this.query = JSON.parse(sessionStorage.getItem('confirmChargeFail'));
		this.initPageText()
	}

	initPageText() {
			
		this.setState({
				moneyFail: '支付失败',
				msgContent: '你的支付出现错误',
				confirmT: '重新支付'
		})

	}

    payAgain() {
		let u = navigator.userAgent;
		let isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
		if (isiOS) {
				 location.href = `/confirmadd`
		} else {
				 browserHistory.go(-1);
		}
	}

	closePage() {
			WeixinJSBridge.invoke('closeWindow',{},function(res){
				//关闭
			});
	}

	render() {

		return (
			<div className="confirm-wapper">
				<div className="confirm-info">
					<div className="cinfo-icon">
							<svg width="80" height="80">
							    <circle cx="40" cy="40" r="40" fill="red"></circle>
									<path d="M24 56 L 56 24" stroke="#fff" strokeWidth="6" fill="transparent"
									strokeLinecap="round" strokeLinejoin="round"/>
									<path d="M24 24 L 56 56" stroke="#fff" strokeWidth="6" fill="transparent"
									strokeLinecap="round" strokeLinejoin="round"/>
							</svg>
          </div>
					<p className="fail-tip">{this.state.moneyFail}</p>
					<p className="cinfo-money">
						{this.state.msgContent}
					</p>
				</div>
				<div className="confirm-handle">
					<div className="handle-btn green-btn" onTouchStart={this.payAgain.bind(this)}>{this.state.confirmT}</div>
					<div className="handle-btn gray-btn" onTouchStart={this.closePage.bind(this)}>确定</div>
				</div>
			</div>

		)
	}
}

module.exports = FailAdd
